package com.zy.cat.common.utils;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

/**
 * @info 自定义Jackson 序列化null 值变为""
 * @author Link
 * @date 2019-07-01 16:22
 * @JsonDeserialize(using = CustomJacksonStringDeserializer.class)
 */
public class CustomJacksonStringDeserializer extends JsonDeserializer<String> {

	@Override
	public String deserialize(JsonParser jsonparser, DeserializationContext deserializationcontext)
			throws IOException, JsonProcessingException {
		return jsonparser.getText();

	}

	@Override
	public String getNullValue() {
		return "";
	}

}
